package com.example.boot_mq_topic_produce.com.mmall;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.jms.Queue;
import javax.jms.Topic;
import java.util.UUID;

/**
 * @ClassName Topic_Produce
 * @Description TODO
 * @Author wushaopei
 * @Date 2019/12/25 16:25
 * @Version 1.0
 */
@Component
public class Topic_Produce {

    @Autowired
    private JmsMessagingTemplate jmsMessagingTemplate;

    @Autowired
    private Topic topic;

    @Autowired
    private Queue queue;

    @Scheduled(fixedDelay =  3000)
    public  void produceMsgScheduled(){
        jmsMessagingTemplate.convertAndSend(topic,"*******Scheduled: " + UUID.randomUUID().toString().substring(0,6));
        System.out.println("**********produceMsgScheduled send ok");
    }
}
